package com.sakuraio.nextj.core;

import java.time.format.DateTimeFormatter;
import java.util.Locale;
import java.util.TimeZone;

/**
 * <p>NextJ</p>
 *
 * @author nekoimi 2023/03/17
 */
public final class NextJ {

    private NextJ() {
    }

    /**
     * 框架名称
     */
    public static final String NEXTJ_FRAMEWORK = "NextJ-Framework";

    /**
     * 框架组件包，自定义包扫描需要扫描
     */
    public static final String NEXTJ_PACKAGE = "com.sakuraio.nextj";

    /**
     * 请求相关常量
     */
    public static final class Request {
        private Request() {
        }

        /**
         * 认证请求头
         */
        public static final String HEADER_AUTHORIZATION = "Authorization";

        /**
         * 认证请求头
         */
        public static final String HEADER_COOKIE = "Cookie";

        /**
         * 认证类型请求头
         */
        public static final String HEADER_LOGIN_TYPE = "X-Login-Type";

        /**
         * 链路追踪ID请求头
         */
        public static final String HEADER_TRACE_ID = "X-Trace-Id";

        /**
         * 放在QueryString上的认证类型
         */
        public static final String QUERY_LOGIN_TYPE = "loginType";

        /**
         * 放在QueryString上的Token
         */
        public static final String QUERY_TOKEN = "token";
    }

    /**
     * Sso 相关常量
     */
    public static final class Sso {
        private Sso() {
        }

        /**
         * 租户ID
         */
        public static final String TENANT_ID = "webflux.sso.tenantId";

        /**
         * 上下文唯一标识
         */
        public static final String IDENTIFIER = "webflux.sso.identifier";

        /**
         * 认证对象名
         */
        public static final String USERNAME = "webflux.sso.username";

        /**
         * 认证对象姓名
         */
        public static final String FULLNAME = "webflux.sso.fullname";

        /**
         * token
         */
        public static final String TOKEN = "webflux.sso.token";

        /**
         * 认证对象
         */
        public static final String JWT_SUBJECT = "webflux.sso.subject";
    }

    /**
     * 日期格式相关
     */
    public static final class DateFormat {
        private DateFormat() {
        }

        public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd";
        public static final String DEFAULT_DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
        public static final DateTimeFormatter DEFAULT_DATE_FORMATTER = DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT, Locale.CHINA);
        public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT, Locale.CHINA);
        public static final TimeZone DEFAULT_TIME_ZONE = TimeZone.getDefault();
    }

    public static final class Cache {
        private Cache() {
        }

        public static final String KEY_PREFIX = "com.sakuraio.nextj";
    }
}
